package com.jeesite.modules.jdProduct.utils;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @描述: 操作员类型 . <br/>
 * 适用于表：
 * TBL_BOSS_OPERATOR， 
 * TBL_MERCHANT_OPERATOR .
 * 
 * @作者: WuShuicheng .
 * @创建时间: 2013-9-12,上午11:16:23 .
 * @版本: 1.0 .
 */
public enum ProvincesEnum {
	
	
	

	
	BEIJING("北京", 1),
	CHONGQING("重庆", 4),
	XINJIANG("新疆", 31),
	GUANGDONG("广东", 19),
	ZHEJIANG("浙江", 15),
	TIANJING("天津", 3),
	GANGAO("港澳", 52993),
	GUANGXI("广西", 20),
	NEIMENGGU("内蒙古", 11),
	NINGXIA("宁夏", 30),
	JIANGXI("江西", 21),
	TAIWAN("台湾", 32),
	ANHUI("安徽", 14),
	GUIZHOU("贵州", 24),
	SANXI("陕西", 27),
	LIAONING("辽宁", 8),
	SHANXI("山西", 6),
	QINGHAI("青海", 29),
	SICHUAN("四川", 22),
	JIANGSHU("江苏", 12),
	HEBEI("河北", 5),
	XIZANG("西藏", 26),
	DIAOYUDAO("钓鱼岛", 84),
	FUJIAN("福建", 16),
	JILIN("吉林", 9),
	YUNNAN("云南", 25),
	HAINAN("海南", 23),
	HUBEI("湖北", 17),
	SHANGHAI("上海", 2),
	HUNAN("湖南", 18),
	GANSHU("甘肃", 28),
	HENAN("河南", 7),
	SHANDONG("山东", 13),
	HEILONGJIANG("黑龙江", 10);
	

	/** 描述 */
	private String name;
	/** 枚举值 */
	private Integer value;

	private ProvincesEnum(String name, Integer value) {
		this.name = name;
		this.value = value;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getValue() {
		return value;
	}

	public void setValue(Integer value) {
		this.value = value;
	}

	public static ProvincesEnum getEnum(Integer value){
		ProvincesEnum resultEnum = null;
		ProvincesEnum[] enumAry = ProvincesEnum.values();
		for(int i = 0;i<enumAry.length;i++){
			if(enumAry[i].getValue().equals(value)){
				resultEnum = enumAry[i];
				break;
			}
		}
		return resultEnum;
	}
	
	public static Map<String, Map<String, Object>> toMap() {
		ProvincesEnum[] ary = ProvincesEnum.values();
		Map<String, Map<String, Object>> enumMap = new HashMap<String, Map<String, Object>>();
		for (int num = 0; num < ary.length; num++) {
			Map<String, Object> map = new HashMap<String, Object>();
			String key = String.valueOf(getEnum(ary[num].getValue()));
			map.put("value", ary[num].getValue());
			map.put("name", ary[num].getName());
			enumMap.put(key, map);
		}
		return enumMap;
	}
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public static List toList(){
		ProvincesEnum[] ary = ProvincesEnum.values();
		List list = new ArrayList();
		for(int i=0;i<ary.length;i++){
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("value",ary[i].getValue());
			map.put("name", ary[i].getName());
			list.add(map);
		}
		return list;
	}
	
	public static String getKey(String value){
		ProvincesEnum[] ary = ProvincesEnum.values();
		
		String result="";
		for(int i=0;i<ary.length;i++){
			

			if(value.equals(ary[i].getValue())){
				result=ary[i].getName();
				break;
			}
		
		}
		return result;
	}
	
	public static Integer getValue(String key){
		ProvincesEnum[] ary = ProvincesEnum.values();

		Integer result=0;
		for(int i=0;i<ary.length;i++){
			
			if(key.equals(ary[i].getName())){
				result=ary[i].getValue();
				break;
			}
		
		}
		return result;
	}
	
	
	public static void main(String[] args) {
		
		System.out.println(toList());
	}

}

